<?php

/**
 * pwai main file
 *
 * loads installer modules and template files
 *
 * PHP version 5
 *
 * LICENSE: This file is part of PHP Web Application Installer also know as PWAI.
 * PWAI is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, version 3 of the License.
 *
 * PWAI is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with KarambitKS.  If not, see <http://www.gnu.org/licenses/>.
 *
 * @author     Michael Cummings <mgcummings@yahoo.com>
 * @author     Stephen Gulickk <stephenmg12@gmail.com>
 * @copyright  2009 (C) Michael Cummings and Stephen Gulick
 * @license    http://www.gnu.org/licenses/gpl-3.0.html GPL 3.0
 * @package    pwai
 * @version    SVN: $Id$
 * @link       http://code.google.com/p/pwai/
 */

//shorter constant for directory_separator 
define('DS', DIRECTORY_SEPARATOR);
//absolute path for directory installer.php is being ran from
$dir = realpath(dirname(__FILE__));
$dir = $dir.DS;
/**
 * PWAI_INSTALLER_BASE absolute path for installer
 */
define('PWAI_INSTALLER_BASE', $dir);

$settings = array('ADODB' => '/ext/adodb', 'DWOO'=> '/ext/dwoo', 'CACHE' =>
    '../cache/', 'CLASS' => '../class/', 'CONFIG' => '../config/', 'TPL' => '../tpl/', 'VIEW' => '../view/', 'EXT'=>'../ext/');
foreach ($settings as $k => $v)
{
    $realpath = realpath($incDir . $ds . $v);
    if ($realpath && is_dir($realpath))
    {
        define('EVEHR_' . $k, $realpath . $ds);
    } else
    {
        $mess = 'Nonexistent directory defined for eveHR_' . $k . ' constant';
        trigger_error($mess, E_USER_ERROR);
    }
    ;
}
; // foreach $settings ...

/**
 * Check PHP version is at least 5.2.1
 */
if (version_compare(PHP_VERSION, '5.2.1', '<')) {
  $mess = 'Need minimum of PHP 5.2.1 to use this software!';
  trigger_error($mess, E_USER_ERROR);
  exit(1);
};

/**
 * Check if required php extensions are loaded
 */
$required = array('curl', 'date', 'mysqli', 'SimpleXML', 'SPL');
$exts = get_loaded_extensions();
foreach ($required as $ext) {
  if (!in_array($ext, $exts)) {
    $mess = 'The required PHP extension ' . $ext . ' is missing!';
    trigger_error($mess, E_USER_ERROR);
    exit(2);
  };
};// foreach $exts ...


require_once'class/xmlLoader.php';

$installConfig = new xmlLoader;
$installConfig->dumpXml();

?>